﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
public partial class User_Shares_Profile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var thisUser = HttpContext.Current.User;
            if (thisUser.Identity.IsAuthenticated)
            {
                if (thisUser.IsInRole("admin") || thisUser.IsInRole("fourthfactor") || thisUser.IsInRole("bonyadshahrestan")
                || thisUser.IsInRole("surveyor") || thisUser.IsInRole("employer"))
                {
                    MultiViewAdvisors.ActiveViewIndex = -1;
                    MultiViewNameFamily.ActiveViewIndex = 0;
                }
                if (thisUser.IsInRole("advisor"))
                {
                    IDataReader dr = DataAccess.TblUserDetail.FetchByParameter(DataAccess.TblUserDetail.Columns.UserId, Membership.GetUser().ProviderUserKey);
                    if (dr.Read())
                    {
                        if (dr["Role"].ToString() == "Advisorhoghooghi")
                        {
                            MultiViewAdvisors.ActiveViewIndex = 0;
                            MultiViewNameFamily.ActiveViewIndex = -1;
                        }
                        else
                        {
                            MultiViewAdvisors.ActiveViewIndex = 1;
                            MultiViewNameFamily.ActiveViewIndex = 0;
                        }
                        dr.Close();
                    }
                }
                ProfileCommon p = Profile.GetProfile(Membership.GetUser().UserName);
                TxtAddress.Text = p.Contacts.Address;
                TxtTel.Text = p.Contacts.Phone1;
                TxtName.Text = p.Common.FirstName;
                TxtFamily0.Text = p.Common.LastName;
                TxtEmail.Text = p.Contacts.Email;
                TxtMobile.Text = p.Contacts.Mobile;
                if (p.Common.City != "")
                    DrpCityhaghighi.Text = p.Common.City;
                if (p.HaghighiAdvisor.IsMemberofenginering != "")
                    DrpIsInEnginering.Text = p.HaghighiAdvisor.IsMemberofenginering;
                if (p.HaghighiAdvisor.GraduateGrade != "")
                    DrpGrade.Text = p.HaghighiAdvisor.GraduateGrade;
                Business.Calender calender = new Business.Calender();
                if (p.HaghighiAdvisor.GraduateDate != "")
                    TextBoxGraduate.Text = calender.MiladiToPersian(Convert.ToDateTime(p.HaghighiAdvisor.GraduateDate).Date);
                if (p.HaghighiAdvisor.Branch != "")
                    DrpBranchhaghighi.Text = p.HaghighiAdvisor.Branch;
                if (p.HoghooghiAdvisor.Branch != "")
                    DrpBranch.Text = p.HoghooghiAdvisor.Branch;
                TxtCompanyName.Text = p.HoghooghiAdvisor.CompanyName;
                TxtCompanyRegCode.Text = p.HoghooghiAdvisor.CompanyRegistrationCode;
                TxtManager.Text = p.HoghooghiAdvisor.Manager;
                if (p.HoghooghiAdvisor.ExtendedBranch != "")
                    DrpExtendedBranch.Text = p.HoghooghiAdvisor.ExtendedBranch;
                TxtCompanyWebSite.Text = p.Contacts.Site;
                TxtworkYears.Text = p.Common.WorkYears;
                if (p.HoghooghiAdvisor.ValidationDate != "")
                    TextBoxValidationDate.Text = calender.MiladiToPersian(Convert.ToDateTime(p.HoghooghiAdvisor.ValidationDate).Date);

            }
        }
        catch
        { 
        }
    }
}